package com.tiendung.otalunch;

import com.google.android.maps.GeoPoint;

public class RestaurantLocation {
    double lat, lng;
	double current_lat, current_long;
    
	public RestaurantLocation(String restaurant) {
		lat = Double.parseDouble(Restaurant.getLat(restaurant));
		lng = Double.parseDouble(Restaurant.getLong(restaurant));
		
	}
	
	public GeoPoint getLocation() {
		return (new GeoPoint(
            (int) (lat * 1E6), 
            (int) (lng * 1E6)));
	}
	
	public GeoPoint getCurrentLocation(double input_lat, double input_long) {
		current_lat = input_lat;
		current_long = input_long;
		
		if (current_lat > 60 && current_lat < 69 && current_long > 21 && current_long < 31)
			return (new GeoPoint(
	            (int) (current_lat * 1E6), 
	            (int) (current_long * 1E6)));
		else
			return null;
	}
	
	public GeoPoint getCenter(double input_lat, double input_long) {
		if (getCurrentLocation(input_lat, input_long) != null)
			return (new GeoPoint(
	            (int) (this.getLocation().getLatitudeE6() + this.getCurrentLocation(input_lat, input_long).getLatitudeE6()) / 2, 
	            (int) (this.getLocation().getLongitudeE6() + this.getCurrentLocation(input_lat, input_long).getLongitudeE6()) / 2)); 
	
		else
			return (new GeoPoint(
	            (int) this.getLocation().getLatitudeE6(), (int) this.getLocation().getLongitudeE6())); 
	}
}
